package com.train.webadmin.app.model;

import com.baomidou.mybatisplus.annotation.*;
import com.train.common.core.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 课程论坛实体对象。
 *
 * @author xulei
 * @date 2025-03-07
 */
@Data
@TableName(value = "course_forum")
public class CourseForum {

    /**
     * id。
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 论坛主题。
     */
    @TableField(value = "theme")
    private String theme;

    /**
     * 创建人。
     */
    @TableField(value = "create_user_id")
    private Long createUserId;

    /**
     * 创建时间。
     */
    @TableField(value = "create_time")
    private Date createTime;

    /**
     * 父级id。
     */
    @TableField(value = "pid")
    private Long pid;

    /**
     * 班级id。
     */
    @TableField(value = "class_id")
    private Long classId;

    /**
     * 更新人。
     */
    @TableField(value = "update_user_id")
    private Long updateUserId;

    /**
     * 分享数量。
     */
    @TableField(value = "share_count")
    private Integer shareCount;

    /**
     * 更新时间。
     */
    @TableField(value = "update_time")
    private Date updateTime;

    /**
     * 逻辑删除标记字段(1: 正常 -1: 已删除)。
     */
    @TableLogic
    @TableField(value = "deleted_flag")
    private Integer deletedFlag;

    /**
     * 学生id。
     */
    @TableField(value = "student_id")
    private Long studentId;

    /**
     * 老师id。
     */
    @TableField(value = "teacher_id")
    private Long teacherId;

    /**
     * 课程id。
     */
    @TableField(value = "course_id")
    private Long courseId;

    /**
     * 是否推荐。
     */
    @TableField(value = "is_recommend")
    private Integer isRecommend;

    @RelationOneToOne(
            masterIdField = "classId",
            slaveModelClass = ClassInfo.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private ClassInfo classInfo;

    @RelationOneToOne(
            masterIdField = "teacherId",
            slaveModelClass = TeacherInfo.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private TeacherInfo teacherInfo;

    @RelationOneToOne(
            masterIdField = "courseId",
            slaveModelClass = CourseInfo.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private CourseInfo courseInfo;

    @RelationOneToOne(
            masterIdField = "studentId",
            slaveModelClass = StudentInfo.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private StudentInfo studentInfo;

    @RelationDict(
            masterIdField = "pid",
            slaveModelClass = CourseForum.class,
            slaveIdField = "id",
            slaveNameField = "theme")
    @TableField(exist = false)
    private Map<String, Object> pidDictMap;

    @RelationDict(
            masterIdField = "classId",
            equalOneToOneRelationField = "classInfo",
            slaveModelClass = ClassInfo.class,
            slaveIdField = "id",
            slaveNameField = "className")
    @TableField(exist = false)
    private Map<String, Object> classIdDictMap;

    @RelationDict(
            masterIdField = "studentId",
            equalOneToOneRelationField = "studentInfo",
            slaveModelClass = StudentInfo.class,
            slaveIdField = "id",
            slaveNameField = "name")
    @TableField(exist = false)
    private Map<String, Object> studentIdDictMap;

    @RelationDict(
            masterIdField = "teacherId",
            equalOneToOneRelationField = "teacherInfo",
            slaveModelClass = TeacherInfo.class,
            slaveIdField = "id",
            slaveNameField = "name")
    @TableField(exist = false)
    private Map<String, Object> teacherIdDictMap;

    @RelationDict(
            masterIdField = "courseId",
            equalOneToOneRelationField = "courseInfo",
            slaveModelClass = CourseInfo.class,
            slaveIdField = "id",
            slaveNameField = "title")
    @TableField(exist = false)
    private Map<String, Object> courseIdDictMap;

    @TableField(exist = false)
    private List<CourseForum> courseForums;

    @TableField(exist = false)
    private List<CourseForumFile> courseForumFiles;

    @TableField(exist = false)
    private Integer likeCount;

    @TableField(value = "reply_user_id")
    private Long replyUserId;

    @TableField(exist = false)
    private Integer isLiked;
}
